/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package billing;

import java.util.HashMap;
import java.util.Vector;

/**
 *
 * @author apple
 */
public class CacheDataModel extends My_Model{
    String id;
    String order_id;
    String product_id;
    String quantity;
    String price;
    String area_id;
    
    public CacheDataModel() throws Exception{
        tableName = "cache_data";
    }
    
    public Vector getElementsByAreaId(String _areaId) throws Exception{
        String sql = String.format("SELECT * FROM %s WHERE area_id = %s", tableName,_areaId);
        return to_models(getData(sql));
    }

    @Override
    public My_Model to_model(HashMap<String, String> data) throws Exception {
        CacheDataModel model = new CacheDataModel();
        model.id = (data.get("id") != null ) ? data.get("id") : "";
        model.order_id = (data.get("order_id") != null ) ? data.get("order_id") : "";
        model.product_id = (data.get("product_id") != null ) ? data.get("product_id") : "";
        model.quantity = (data.get("quantity") != null ) ? data.get("quantity") : "";
        model.price = (data.get("price") != null ) ? data.get("price") : "";
        model.area_id = (data.get("area_id") != null ) ? data.get("area_id") : "";
        
        return model;
    }
    
    
}
